home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / debug / memmon.dir / 00022_Script_Main < prev    next >
Text File  |  1995-02-15  |  12KB  |  320 lines

  1. -- Memmon Authoring tool for Director 4.0 mac, windows and soon 3DO.   vers 2.1 11/05/94  
  2. -- By Alex Zavatone 5:53 am 11/7/94
  3. -- 3360 Scott St. #3 S.F. CA. 94123
  4. -- AZavatone@Macromedia.com
  5. -- Property of Alex Zavatone.  Do not distribute without permission - Santa's watching.
  6. -- The Memmon Authoring tool is shareware $15.  Pay me or I sic uncle Guido on your kids. 
  7.  
  8. -- Thanks to Jason Yeaman of Macromedia Tech support for the Cast analyzer
  9.  
  10. -- Functions & Directions for use:
  11. -- ╩╩╩Open as a Miaw with the window name "memmon".   The arrows let you control to what depth memmon monitors memory.  The fastest is
  12. -- Graph only.  Click the left arrow to select Graph display only.  Click the up arrow to only display graph and text readout.
  13. --   ╩╩The preload/unload buttons allow you to control the memmory in the stage movie.  Preload attempts to preload everything in the main 
  14. -- movie.  Unload attempts to unload everything but what is being used on the stage in the main movie.  PreloadCast and UnloadCast 
  15. -- attempt to preload or unload the castmembers listed in the Casts text items.  A check is put in of you attempt to load a castmember past
  16. -- the end of the cast, it will load up to the last cast and not post an alert as in previous (<2.1) versions.  PreloadFrame and UnloadFrame
  17. -- work in the same manner.
  18. --   ╩╩A text field exists in the main display for performance reasons.  When a preload or unload button is pressed, the time to preload or
  19. -- unload is recorded and displayed in that field.  BIG TIP: Burn a CD with the memmon on it as a miaw.  You can preload and unload casts
  20. -- and see how long it takes to do so.  Cool!  If you know the size of the items you are loading or unloading, you can determine the actual
  21. -- CD throughput by using that division thing you learned in third grade.
  22. --   ╩╩The little gray boxes, called tabs, change what is being displayed in the memmon.  The left most tab is for general display.
  23. -- Everytime you expand or contract the window using the arrows, you are returned to the general display.  If your director movie loads other
  24. -- movies and you want to keep track of the current file in memory, select the middle tab.  In this display, my name gets bumped off the 
  25. -- screen and is replaced by the filename of the movie on the stage.  The rightmost button is the sound and monitor control center.  Here, 
  26. -- you can change the colordepth of your stage monitor (if you are on a mac or PPC) and you can control the master soundlevel and the 
  27. -- soundlevels of channels one and two.
  28. --   ╩╩If you mistakenly mess up or close the window, type memmon in the message window.  It will reopen at the default size.
  29. --
  30. --  What not to do:
  31. --   ╩╩Do not clear globals.  I could add a check to see if the globals have been cleared and reinstantiate them but that could be slow.  
  32. -- Let me know it it would be helpful.  Do not clear the windowlist or the memmon window will go away.
  33. -- Please don't snarf the lingo or redistribute without my permission.  
  34. --
  35. -- What could happen:
  36. --   ╩╩I could add more stuff.  Like help or something you think of (Email: AZavatone@Macromadia.com).  You could get an update.
  37. -- I have a filemaker db of cool folks who registered this product and they will be notified when updates are ready.  Send me your
  38. -- Email address and feedback. - Enjoy Zav
  39. --
  40. -- History of Changes:
  41. -- memmon .9
  42. -- First incarnation.  Showed the total memory and amount used/free in a miaw bar chart.
  43.  
  44. -- memmon .95
  45. -- added text readout of the memsize, freebytes and mem used
  46. -- added preloading and unloading of casts, frames, and the entire movie
  47. -- added the flashing indicator to show when the data updates
  48. -- Added informative text.
  49.  
  50. -- memmon 1.0
  51. -- Cleaned up frame input text fields.
  52. -- Added the freeblock to the text output and the main graph.
  53.  
  54. -- memmon 1.4
  55. -- I have no idea.
  56.  
  57. -- memmon 1.5
  58. -- Added the time to perform an preload/unload measuring stats.
  59.  
  60. -- memmon 2.0
  61. -- Created a custom font and shrunk fonts for best display on small monitors.
  62. -- Added time measurement for preloading and unloading in tics and secs.
  63. -- Added resize stage arrows
  64. -- Cleaned up button alignment
  65.  
  66. -- memmon 2.1
  67. -- Optimized resize behavior.  Added Documentation.  
  68. -- Added Tab buttons to show multiple screens.
  69. -- Added show filename & adjust controls screens.
  70. -- Optimized performance to only update what is on screen.  Plain graph is 3x faster.
  71. -- Added the sound controls and colordepth controls.
  72. -- Put range checking in preload cast and unload cast buttons.
  73. -- New graphics
  74. -- Changed how window resizes.  Refers to window "memmon" and alerts if it does not exits.
  75.  
  76. -- memmon 2.11
  77. -- made volumes adjust on mousedown (on the fly) rather  than only on mouseUp
  78.  
  79. -- memmon 2.2
  80. -- Added Tempo control.  This controls how often memmon checks memory.  Less checks = faster performance. 
  81.  
  82. --In the works.  
  83. -- work out window resizing for windows.
  84.  
  85. -- Credits & Thanks.  
  86. -- Producer, Director, Author, Key Grip and Stunt Double - Alex Zavatone
  87. -- Thanks to the rest of the Director Team for a killer product and good times over the last year.  Also thanks to the QA team for input to make
  88. -- the memmon more useful.  Walker, Void and Lalit for the Mosaic Player.  Walker for most frags on a P5 90 - Void for discovering the best
  89. -- uses of the double barrel shotgun.  doomheads.
  90.  
  91. On StartMovie
  92.   CheckForValidName
  93.   InitGlobals
  94.   InitConditions  
  95.   InitPuppets 
  96. end 
  97.  
  98. On CheckForValidName
  99.   set flag = 0
  100.   repeat with temp = 1 to count(the windowlist)
  101.     if the title of window temp =  "memmon" then set flag = 1
  102.   end repeat
  103.   if the windowList = [] or not flag then alert "Please open the memmon with the title Memmon.  Like this: From the message window, type - Open window "&Quote&"memmon"&Quote&".   Open the main movie script for help.           Thank you, the management." 
  104. end 
  105.  
  106. on InitGlobals
  107.   global gBar, gOtherBar,  gStartCast, gEndCast, gStartFrame, gEndFrame, gLevel, gTemp, gTempo
  108.   set gBar = 10
  109.   set gOtherBar = 26
  110.   set gStartCast = the value of field "CastStart"
  111.   set gEndCast = the value of field "CastEnd"
  112.   set gStartFrame = the value of field "FrameStart"
  113.   set gEndFrame = the value of field "FrameEnd"
  114.   set gTemp = 0
  115.   set gTempo = 5
  116.   set gLevel = 2
  117.   --gLevels = 1 = draw graph
  118.   --                 = 2 = updatetext
  119.   --                 = 3 = update filename
  120. end
  121.  
  122. on InitConditions
  123.   set the floatprecision = 3
  124. end
  125.  
  126. on InitPuppets  
  127.   global gBar
  128.   puppetSprite gBar, true
  129.   puppetSprite gOtherBar, true
  130.   puppetSprite 29, true
  131.   puppetSprite 30, true
  132.   puppetSprite 31,true
  133.   puppetSprite 32, true
  134.   puppetSprite 33, true
  135.   puppetSprite 34, true
  136. end
  137.  
  138. on Dome  
  139.   -- inittime
  140.   global gLevel 
  141.   UpdateGraph  
  142.   if gLevel > 1 then
  143.     UpdateFields
  144.   end if 
  145.   --  checktime
  146. end 
  147.  
  148. on UpdateGraph
  149.   global gBar, gOtherBar
  150.   if voidP(gBar) then startmovie
  151.   --   inittime
  152.   -- set firstbar, freebytes
  153.   set the height of sprite gBar = the height of cast "border" *  ( the freeBytes * 1.0) /  the memorySize   + 1.0  
  154.   -- set otherBar, the freeblock
  155.   set the height of sprite gOtherBar = the height of cast "border" *  ( the freeBlock* 1.0) / the memorySize   + 1.0
  156.   
  157.   
  158.   --checktime
  159. end 
  160.  
  161. on UpdateFields
  162.   put the memorysize &" = "& the memorySize/1024&"k" into field "memsize"
  163.   put the freebytes &" = "& the freebytes/1024&"k" into field "freebytes"
  164.   put the freeblock &" = "& the freeblock/1024&"k" into field "freeblock"
  165.   put the memorySize - the freebytes &" = "& (the memorySize - the freeBytes)/1024&"k" into field "MemUsed" 
  166.   
  167. end
  168.  
  169. on GetValues
  170.   global gStartCast, gEndCast, gStartFrame, gEndFrame, gTemp
  171.   set gStartCast = the value of field "CastStart"
  172.   set gEndCast = the value of field "CastEnd"
  173.   set gStartFrame = the value of field "FrameStart"
  174.   set gEndFrame = the value of field "FrameEnd"  
  175.   tell the stage to put the number of castMembers into gTemp
  176.   if gEndCast > gTemp then set gEndCast = gTemp
  177. end
  178.  
  179. --- Time measurement
  180.  
  181. on StartTimer
  182.   return the ticks
  183. end
  184.  
  185. on PutTime now
  186.   set delta = the ticks - now
  187.   put "ticks = " & delta into field "delta t"
  188.   put Return & "secs = "& delta/60.0 after field "delta t"
  189. end
  190.  
  191. -- debug time calls
  192. on InitTime
  193.   global gNow
  194.   set gnow = the ticks
  195. end
  196.  
  197. on CheckTime
  198.   global gNow
  199.   put the ticks - gNow
  200. end
  201.  
  202. --- Button control
  203.  
  204.  
  205. on DoRight
  206.   set the castnum of sprite the clickon to the number of cast "Left" 
  207.   set wind = window "memmon"
  208.   set leftSide = getat( the rect of wind, 1)
  209.   set topSide =  getat( the rect of wind, 2)
  210.   set rightSide =  getat( the rect of wind, 3)
  211.   set bottomSide = getat( the rect of wind, 4)
  212.   set the rect of wind = rect(leftSide, topSide, rightSide + 128, bottomSide) 
  213. end
  214.  
  215. on DoLeft
  216.   set the castnum of sprite the clickon to the number of cast "Right"
  217.   set wind = window "memmon"
  218.   set leftSide = getat( the rect of wind, 1)
  219.   set topSide =  getat( the rect of wind, 2)
  220.   set rightSide =  getat( the rect of wind, 3)
  221.   set bottomSide = getat( the rect of wind, 4)
  222.   set the rect of wind = rect(leftSide, topSide, rightSide - 128, bottomSide) 
  223. end
  224.  
  225. on DoUp arrow
  226.   if voidP(arrow)  then
  227.     set the castnum of sprite the clickon to the number of cast "down"
  228.   else
  229.     set the castnum of sprite 29 to 0 
  230.     updatestage
  231.   end if
  232.   
  233.   set wind = window "memmon"
  234.   set leftSide = getat( the rect of wind, 1)
  235.   set topSide =  getat( the rect of wind, 2)
  236.   set rightSide =  getat( the rect of wind, 3)
  237.   set bottomSide = getat( the rect of wind, 4)
  238.   set the rect of wind = rect(leftSide, topSide, rightSide, bottomSide - 86) 
  239. end
  240.  
  241. on DoDown arrow
  242.   if voidP(arrow)  then
  243.     set the castnum of sprite the clickon to the number of cast "up"
  244.   else
  245.     set the castnum of sprite 29 to the number of cast "up"
  246.   end if
  247.   
  248.   set wind = window "memmon"
  249.   set leftSide = getat( the rect of wind, 1)
  250.   set topSide =  getat( the rect of wind, 2)
  251.   set rightSide =  getat( the rect of wind, 3)
  252.   set bottomSide = getat( the rect of wind, 4)
  253.   set the rect of wind = rect(leftSide, topSide, rightSide, bottomSide + 86) 
  254. end
  255.  
  256. --- get moviename
  257.  
  258. on GetMainMovieName
  259.   global gMovie
  260.   tell the stage to set gMovie = the movieName 
  261.   put gMovie into field "Moviename"
  262. end
  263.  
  264. ---
  265. on ResetTabButtons
  266.   set the backcolor of sprite 31 = 250
  267.   set the backcolor of sprite 32 = 245
  268.   set the backcolor of sprite 33 = 245
  269.   set the backcolor of sprite 34 = 245
  270. end
  271.  
  272. ---
  273. On TurnOffDepthPuppets
  274.   repeat with temp = 13 to 17
  275.     puppetSprite temp, 0 
  276.   end repeat
  277. end 
  278.  
  279. On TurnOffVolumePuppets
  280.   repeat with temp = 35 to 40
  281.     puppetsprite temp, 0
  282.     puppetsprite temp, 0
  283.   end repeat
  284. end
  285.  
  286. on UpdateMeters
  287.   -- update main vol meter
  288.   set mainVolHeight = (64 - (9 * the soundLevel  ))
  289.   set the height of sprite 35 = mainVolHeight
  290.   set the locV of sprite 38 = 69 + mainVolHeight - 3
  291.   
  292.   -- update vol 1 meter
  293.   set mainVolHeight = (64 - (0.251 * the volume of sound 1 ))
  294.   set the height of sprite 36 = mainVolHeight
  295.   set the locV of sprite 39 = 69 + mainVolHeight - 3
  296.   
  297.   -- update vol 2 meter
  298.   set mainVolHeight = (64 - (0.251 * the volume of sound 2  ))
  299.   set the height of sprite 37 = mainVolHeight
  300.   set the locV of sprite 40 = 69 + mainVolHeight - 3
  301. end
  302.  
  303. on Memmon 
  304.   -- We are not foolproof
  305.   go frame 1
  306.   set the rect of window "memmon" = the sourceRect of window "memmon"
  307.   open window "memmon"
  308. end
  309.  
  310. on InitTempoIndicator
  311.   global gTempo
  312.   puppetSprite 22,0
  313.   puppetSprite 22,1
  314.   set the locV of sprite 22 = the bottom of sprite 21  - gTempo * 3 - 1
  315. end
  316.  
  317. On TurnOffTempoPuppets
  318.   puppetSprite 22,0
  319. end
  320.